package com.socodethis.spaceex;

import java.util.ArrayList;

import com.socodethis.spaceex.math.cPoint;

public abstract class switchClass {
	private boolean switchOn;
	private cPoint switchLocation, connectingLocation;
	boolean buttonStillOff;
	
	public switchClass(switchClass switches){
		this.switchOn=switches.switchOn;
		this.switchLocation = new cPoint(switches.switchLocation);
		this.connectingLocation = new cPoint(switches.connectingLocation);
	}
	
	//Right now this is assuming that the button only controls one door
	public switchClass(boolean switchOn, cPoint switchLocation, cPoint connectingLocation){
		this.switchOn=switchOn;
		this.switchLocation = new cPoint(switchLocation);
		this.connectingLocation = new cPoint(connectingLocation);
	}
	public boolean getButtonOn(){
		return switchOn;
	}
	public void switchButton(){
		this.switchOn = !switchOn;
	}
	public boolean shouldSwitchButton(ArrayList<buttonClass> buttons){
		buttonStillOff = false;
		for(buttonClass button:buttons){
			if(button.getDoor().cEquals(switchLocation) && !button.getButtonOn()){
				buttonStillOff = true;
			}
		}
		return !buttonStillOff;
	}
	public cPoint getDoor(){
		return switchLocation;
	}
	public cPoint getButtonLocation(){
		return connectingLocation;
	}
}
